<?php
namespace app\api\controller;

use think\Request;

    /**
     * @SWG\Swagger(
     * schemes={"https","http"},
     * host="wx.hncegbim.com/api/Jiaotong",
     * consumes={"multipart/form-data"},
     * produces={"application/json"},
     * @SWG\Info(
     * version="1.0",
     * title="上海交大",
     * description="上海交大接口文档<br> 以后就在这里愉快的对接口把!<br>"
     * ),
     *
     * @SWG\Tag(
     * name="Index",
     * description="登入模块",
     * ),
     * @SWG\Tag(
     * name="Storage",
     * description="入库模块",
     * ),
     * @SWG\Tag(
     * name="Collar",
     * description="领用模块",
     * ),
     * @SWG\Tag(
     * name="Equipment",
     * description="购买器材模块",
     * ),
     * @SWG\Tag(
     * name="Goods",
     * description="产品模块",
     * ),
     * @SWG\Tag(
     * name="ItemAdd",
     * description="项目模块",
     * ),
     * @SWG\Tag(
     * name="ApplyType",
     * description="申请模块",
     * ),
     * @SWG\Tag(
     * name="Whereabouts",
     * description="去向模块",
     * ),
     * @SWG\Tag(
     * name="Duty",
     * description="值日模块",
     * ),
     * @SWG\Tag(
     * name="Remarks",
     * description="备注模块",
     * ),
     * )
     */

class Jiaotong extends Base
{   
    /**
     * @SWG\Post(
     * path="/Index",
     * tags={"Index"},
     * summary="登入",
     * description="登入-吴辉",
     * @SWG\Parameter(name="mstr", description="加密KEY", in="formData", required=true, type="string"),
     * @SWG\Parameter(name="tel", description="手机号码", in="formData", required=false, type="integer"),
     * @SWG\Parameter(name="pwd", description="密码", in="formData", required=false, type="integer"),
     *
     * @SWG\Response(
     * response=200,
     * description="成功返回数据",
     * )
     * )
     */
    public function Index()
    {
        $post = request()->only(['tel','pwd'], 'post');
        
        if (empty($post['tel'])){
            err('手机号码不能为空');
        }
        
        if (empty($post['pwd'])){
            err('密码不能为空');
        }
        
        $res = db('wh_jd_user')->field('id,name')->where(['tel'=>$post['tel'],'pwd'=>md5($post['pwd'])])->find();
        if (!$res){
            err('手机号码或者密码不正确');
        }else{
            suc('登入成功',$res);
        }
    }
    
    /**
     * @SWG\Post(
     * path="/Company",
     * tags={"Index"},
     * summary="单位",
     * description="单位-吴辉",
     * @SWG\Parameter(name="mstr", description="加密KEY", in="formData", required=true, type="string"),
     * @SWG\Response(
     * response=200,
     * description="成功返回数据",
     * @SWG\Header(header="title", type="string", description="单位名称")
     * )
     * )
     */
    public function Company()
    {
        $res = db('wh_jd_company')->field('title')->select();
        if (!$res){
            err('暂无数据');
        }else{
            suc('',$res);
        }
    }
    
    /**
     * @SWG\Post(
     * path="/Storage",
     * tags={"Storage"},
     * summary="入库",
     * description="入库-吴辉",
     * @SWG\Parameter(name="mstr", description="加密KEY", in="formData", required=true, type="string"),
     * @SWG\Parameter(name="item_name", description="物品名称", in="formData", required=false, type="integer"),
     * @SWG\Parameter(name="time", description="入库时间", in="formData", required=false, type="integer"),
     * @SWG\Parameter(name="name", description="入库人员", in="formData", required=false, type="integer"),
     * @SWG\Parameter(name="time_end", description="到期时间", in="formData", required=false, type="integer"),
     * @SWG\Parameter(name="count", description="入库量", in="formData", required=false, type="integer"),
     * @SWG\Parameter(name="company", description="单位", in="formData", required=false, type="integer"),
     * @SWG\Parameter(name="img", description="存放位置", in="formData", required=false, type="integer"),
     *
     * @SWG\Response(
     * response=200,
     * description="成功返回数据",
     * )
     * )
     */
    public function Storage()
    {
        $post = request()->only(['item_name','time','user_name','time_end','count','img','company'], 'post');
        
        if (empty($post['item_name'])){
            err('物品名称不能为空');
        }
        if (empty($post['time'])){
            err('入库时间不能为空');
        }
        if (empty($post['user_name'])){
            err('入库人员不能为空');
        }
        if (empty($post['time_end'])){
            err('到期时间不能为空');
        }
        if (empty($post['count'])){
            err('入库量不能为空');
        }
        if (empty($post['company'])){
            err('单位不能为空');
        }
        if (empty($post['img'])){
            err('存放位置不能为空');
        }
        
        $data['item_name'] = $post['item_name'];
        $data['time'] = $post['time'];
        $data['user_name'] = $post['user_name'];
        $data['time_end'] = $post['time_end'];
        $data['count'] = $post['count'];
        $data['company'] = $post['company'];
        $data['img'] = json_encode($post['img']);
        $data['create_time'] = time();
        
        $arr = db('wh_jd_storage')->where(['item_name'=>$post['item_name']])->find();
        if ($arr){
            $res = db('wh_jd_storage')->where(['id'=>$arr['id']])->update(['count'=>$post['count']]);
        }else{
            $res = db('wh_jd_storage')->insert($data);
        }
        
        if (!$res){
            err('入库失败');
        }else{
            suc('入库成功');
        }
        
    }
    
    /**
     * @SWG\Post(
     * path="/Sample",
     * tags={"Storage"},
     * summary="入库样品",
     * description="入库样品-吴辉",
     * @SWG\Parameter(name="mstr", description="加密KEY", in="formData", required=true, type="string"),
     * @SWG\Response(
     * response=200,
     * description="成功返回数据",
     * @SWG\Header(header="item_name", type="string", description="样品名称"),
     * @SWG\Header(header="count", type="string", description="库存量"),
     * )
     * )
     */
    public function Sample()
    {
        $res = db('wh_jd_storage')->field('item_name,count')->select();
        if (!$res){
            err('暂无数据');
        }else{
            suc('',$res);
        }
    }
    /**
     * @SWG\Post(
     * path="/Collar",
     * tags={"Collar"},
     * summary="领用",
     * description="领用-吴辉",
     * @SWG\Parameter(name="mstr", description="加密KEY", in="formData", required=true, type="string"),
     * @SWG\Parameter(name="item_name", description="样品名称", in="formData", required=false, type="integer"),
     * @SWG\Parameter(name="name", description="领用人", in="formData", required=false, type="integer"),
     * @SWG\Parameter(name="consumption", description="领用量", in="formData", required=false, type="integer"),
     * @SWG\Parameter(name="content", description="备注说明", in="formData", required=false, type="integer"),
     *
     * @SWG\Response(
     * response=200,
     * description="成功返回数据",
     * )
     * )
     */
    public function Collar()
    {
        $post = request()->only(['item_name','name','consumption','content'], 'post');
        
        if (empty($post['item_name'])){
            err('入库样品不能为空');
        }
        if (empty($post['name'])){
            err('领用人不能为空');
        }
        if (empty($post['consumption'])){
            err('领用量不能为空');
        }
        if (!empty($post['content'])){
            $data['content'] = $post['content'];
        }
        
        $data['item_name'] = $post['item_name'];
        $data['name'] = $post['name'];
        $data['consumption'] = $post['consumption'];
        $data['create_time'] = date("Y-m-d");
        
        $res = db('wh_jd_collar')->insert($data);
        if (!$res){
            err('领用失败');
        }else{
            //减去库存量
            $str = db('wh_jd_storage')->field('count')->where(['item_name'=>$post['item_name']])->find();
            $count = $str['count'] - $post['consumption'];
            db('wh_jd_storage')->where(['item_name'=>$post['item_name']])->update(['count'=>$count]);
            suc('领用成功');
        }
    }
    
    /**
     * @SWG\Post(
     * path="/Equipment",
     * tags={"Equipment"},
     * summary="购买器材",
     * description="购买器材-吴辉",
     * @SWG\Parameter(name="mstr", description="加密KEY", in="formData", required=true, type="string"),
     * @SWG\Parameter(name="item_name", description="物品名称", in="formData", required=false, type="integer"),
     * @SWG\Parameter(name="name", description="申请人", in="formData", required=false, type="integer"),
     * @SWG\Parameter(name="content", description="用途说明", in="formData", required=false, type="integer"),
     * @SWG\Parameter(name="image", description="合同", in="formData", required=false, type="integer"),
     * @SWG\Parameter(name="img", description="发票", in="formData", required=false, type="integer"),
     *
     * @SWG\Response(
     * response=200,
     * description="成功返回数据",
     * )
     * )
     */
    public function Equipment()
    {
        $post = request()->only(['item_name','name','content','image','img'], 'post');
        
        if (empty($post['item_name'])){
            err('物品名称不能为空');
        }
        if (empty($post['name'])){
            err('申请人不能为空');
        }
        if (!empty($post['content'])){
            $data['content'] = $post['content'];
        }
        if (empty($post['image'])){
            err('合同图片不能为空');
        }
        if (empty($post['img'])){
            err('发票图片不能为空');
        }
        
        $data['item_name'] = $post['item_name'];
        $data['name'] = $post['name'];
        $data['image'] = json_encode($post['image']);
        $data['img'] = json_encode($post['img']);
        $data['create_time'] = date("Y-m-d");
        $res = db('wh_jd_equipment')->insert($data);
        
        if (!$res){
            err('申请失败');
        }else{
            suc('申请成功');
        }
        
    }
    
    /**
     * @SWG\Post(
     * path="/Goods",
     * tags={"Goods"},
     * summary="产品列表",
     * description="产品列表-吴辉",
     * @SWG\Parameter(name="mstr", description="加密KEY", in="formData", required=true, type="string"),
     * @SWG\Parameter(name="page", description="分页", in="formData", required=false, type="integer"),
     * @SWG\Parameter(name="pagesize", description="页数", in="formData", required=false, type="integer"),
     *
     * @SWG\Response(
     * response=200,
     * description="成功返回数据",
     * )
     * )
     */
    public function Goods()
    {
        $post = request()->only(['page','pagesize'], 'post');
        if (! isset($post['page'])) {
            $post['page'] = 0; // 分页页数
        }
        
        if (! isset($post['pagesize'])) {
            $post['pagesize'] = 10; // 分页条数
        }
        $page = $post['page'];
        $pagesize = $post['pagesize'];
        $res = db('wh_jd_goods')->page($page, $pagesize)->select();
        
        if (!$res){
            err('暂无数据');
        }else{
            suc('',$res);
        }
    }
    
    /**
     * @SWG\Post(
     * path="/ItemAdd",
     * tags={"ItemAdd"},
     * summary="添加项目",
     * description="添加项目-吴辉",
     * @SWG\Parameter(name="mstr", description="加密KEY", in="formData", required=true, type="string"),
     * @SWG\Parameter(name="title", description="标题", in="formData", required=false, type="integer"),
     * @SWG\Parameter(name="content", description="内容", in="formData", required=false, type="integer"),
     * @SWG\Parameter(name="name", description="人员", in="formData", required=false, type="integer"),
     *
     * @SWG\Response(
     * response=200,
     * description="成功返回数据",
     * )
     * )
     */
    public function ItemAdd()
    {
        $post = request()->only(['title','content','name'], 'post');
        if (empty($post['title'])){
            err('项目标题不能为空');
        }
        if (empty($post['content'])){
            err('项目内容不能为空');
        }
        if (empty($post['name'])){
            err('人员不能为空');
        }
        $data['title'] = $post['title'];
        $data['name'] = $post['name'];
        $data['content'] = $post['content'];
        $data['create_time'] = date("Y-m-d");
        $res = db('wh_jd_item')->insert($data);
        if (!$res){
            err('添加失败');
        }else{
            suc('添加成功');
        }
    }
    
    /**
     * @SWG\Post(
     * path="/ItemList",
     * tags={"ItemAdd"},
     * summary="项目列表",
     * description="项目列表-吴辉",
     * @SWG\Parameter(name="mstr", description="加密KEY", in="formData", required=true, type="string"),
     * @SWG\Parameter(name="page", description="分页", in="formData", required=false, type="integer"),
     * @SWG\Parameter(name="pagesize", description="分页数", in="formData", required=false, type="integer"),
     *
     * @SWG\Response(
     * response=200,
     * description="成功返回数据",
     * @SWG\Header(header="id", type="string", description="项目ID"),
     * @SWG\Header(header="title", type="string", description="标题"),
     * @SWG\Header(header="content", type="string", description="内容"),
     * @SWG\Header(header="create_time", type="string", description="时间"),
     * @SWG\Header(header="state", type="string", description="状态 0进行中 1已完成"),
     * )
     * )
     */
    public function ItemList()
    {
        $post = request()->only(['page','pagesize'], 'post');
        if (! isset($post['page'])) {
            $post['page'] = 0; // 分页页数
        }
        
        if (! isset($post['pagesize'])) {
            $post['pagesize'] = 10; // 分页条数
        }
        $page = $post['page'];
        $pagesize = $post['pagesize'];
        $res = db('wh_jd_item')->page($page,$pagesize)->select();
        if (!$res){
            err('暂无数据');
        }else{
            suc('',$res);
        }
    }
    
    /**
     * @SWG\Post(
     * path="/ItemDel",
     * tags={"ItemAdd"},
     * summary="项目删除",
     * description="项目删除-吴辉",
     * @SWG\Parameter(name="mstr", description="加密KEY", in="formData", required=true, type="string"),
     * @SWG\Parameter(name="id", description="项目ID", in="formData", required=false, type="integer"),
     *
     * @SWG\Response(
     * response=200,
     * description="成功返回数据",
     * )
     * )
     */
    public function ItemDel()
    {
        $post = request()->only(['id'], 'post');
        if (empty($post['id'])){
            err('项目ID不能为空');
        }
        $res = db('wh_jd_item')->where(['id'=>$post['id']])->delete();
        if (!$res){
            err('删除失败');
        }else{
            suc('删除成功');
        }
    }
    
    /**
     * @SWG\Post(
     * path="/ItemSpeed_Add",
     * tags={"ItemAdd"},
     * summary="项目进度添加",
     * description="项目进度添加-吴辉",
     * @SWG\Parameter(name="mstr", description="加密KEY", in="formData", required=true, type="string"),
     * @SWG\Parameter(name="id", description="项目ID", in="formData", required=false, type="integer"),
     *
     * @SWG\Response(
     * response=200,
     * description="成功返回数据",
     * @SWG\Header(header="item-title", type="string", description="项目标题"),
     * @SWG\Header(header="item-name", type="string", description="人员"),
     * @SWG\Header(header="item-content", type="string", description="题目"),
     * @SWG\Header(header="item-state", type="string", description="状态"),
     * @SWG\Header(header="item-create_time", type="string", description="创建时间"),
     * @SWG\Header(header="speed-content", type="string", description="进度描述"),
     * @SWG\Header(header="speed-create_time", type="string", description="进度时间"),
     * ),
     * )
     */
    public function ItemSpeed_List()
    {
        $post = request()->only(['id'], 'post');
        if (empty($post['id'])){
            err('项目ID不能为空');
        }
        $res['item'] = db('wh_jd_item')->where(['id'=>$post['id']])->find();
        $res['item']['speed'] = db('wh_jd_speed')->field('content,create_time')->where(['cid'=>$post['id']])->select();
        if (!$res){
            err('暂无数据');
        }else{
            suc('',$res);
        }
    }
    
    /**
     * @SWG\Post(
     * path="/ItemSpeed_Add",
     * tags={"ItemAdd"},
     * summary="项目进度添加",
     * description="项目进度添加-吴辉",
     * @SWG\Parameter(name="mstr", description="加密KEY", in="formData", required=true, type="string"),
     * @SWG\Parameter(name="cid", description="项目ID", in="formData", required=false, type="integer"),
     * @SWG\Parameter(name="title", description="进度信息", in="formData", required=false, type="integer"),
     * @SWG\Parameter(name="content", description="进度描述", in="formData", required=false, type="integer"),
     * @SWG\Parameter(name="image", description="图片", in="formData", required=false, type="integer"),
     *
     * @SWG\Response(
     * response=200,
     * description="成功返回数据",
     * )
     * )
     */
    public function ItemSpeed_Add()
    {
        $post = request()->only(['cid','title','content','image'], 'post');
        if (empty($post['cid'])){
            err('项目ID不能为空');
        }
        if (empty($post['title'])){
            err('进度信息不能为空');
        }
        if (empty($post['content'])){
            err('进度描述不能为空');
        }
        if (!empty($post['image'])){
            $data['image'] = json_encode($post['image']);
        }
        $data['cid'] = $post['cid'];
        $data['title'] = $post['title'];
        $data['content'] = $post['content'];
        $data['create_time'] = date("Y-m-d");
        $res = db('wh_jd_speed')->insert($data);
        if (!$res){
            err('添加失败');
        }else{
            suc('添加成功');
        }
        
    }
    
    /**
     * @SWG\Post(
     * path="/ApplyType",
     * tags={"ApplyType"},
     * summary="申请性质类型",
     * description="申请性质类型-吴辉",
     * @SWG\Parameter(name="mstr", description="加密KEY", in="formData", required=true, type="string"),
     * @SWG\Response(
     * response=200,
     * description="成功返回数据",
     * @SWG\Header(header="name", type="string", description="性质名称"),
     * )
     * )
     */
    public function ApplyType()
    {
        $res = db('wh_jd_type')->field('name')->select();
        if (!$res){
            err('暂无数据');
        }else{
            suc('',$res);
        }
    }
    
    /**
     * @SWG\Post(
     * path="/ApplyAdd",
     * tags={"ApplyType"},
     * summary="发起申请",
     * description="发起申请-吴辉",
     * @SWG\Parameter(name="mstr", description="加密KEY", in="formData", required=true, type="string"),
     * @SWG\Parameter(name="nature", description="性质", in="formData", required=false, type="integer"),
     * @SWG\Parameter(name="name", description="申请人", in="formData", required=false, type="integer"),
     * @SWG\Parameter(name="time_start", description="开始时间", in="formData", required=false, type="integer"),
     * @SWG\Parameter(name="time_end", description="结束时间", in="formData", required=false, type="integer"),
     * @SWG\Parameter(name="content", description="事由", in="formData", required=false, type="integer"),
     *
     * @SWG\Response(
     * response=200,
     * description="成功返回数据",
     * 
     * )
     * )
     */
    public function ApplyAdd()
    {
        $post = request()->only(['nature','name','time_start','time_end','content'], 'post');
        if (empty($post['nature'])){
            err('申请性质不能为空空');
        }
        if (empty($post['name'])){
            err('申请人不能为空');
        }
        if (empty($post['time_start'])){
            err('开始日期不能为空');
        }
        if (empty($post['time_end'])){
            err('结束日期不能为空');
        }
        if (!empty($post['content'])){
            $data['content'] = $post['content'];
        }
        $data['nature'] = $post['nature'];
        $data['name'] = $post['name'];
        $data['time_start'] = $post['time_start'];
        $data['time_end'] = $post['time_end'];
        $data['create_time'] = date("Y-m-d"); 
        $res = db('wh_jd_apply')->insert($data);
        
        if (!$res){
            err('提交失败');
        }else{
            suc('申请成功待审批');
        }
    }
    
    /**
     * @SWG\Post(
     * path="/ApplyList",
     * tags={"ApplyType"},
     * summary="申请列表",
     * description="申请列表-吴辉",
     * @SWG\Parameter(name="mstr", description="加密KEY", in="formData", required=true, type="string"),
     * @SWG\Parameter(name="page", description="分页", in="formData", required=false, type="integer"),
     * @SWG\Parameter(name="pagesize", description="分页页数", in="formData", required=false, type="integer"),
     * @SWG\Response(
     * response=200,
     * description="成功返回数据",
     * @SWG\Header(header="name", type="string", description="申请人"),
     * @SWG\Header(header="nature", type="string", description="性质"),
     * @SWG\Header(header="time_start", type="string", description="开始时间"),
     * @SWG\Header(header="time_end", type="string", description="结束时间"),
     * @SWG\Header(header="state", type="string", description="状态0待审核 1已审核2未通过"),
     * )
     * )
     */
    public function ApplyList()
    {
        $post = request()->only(['page','pagesize'], 'post');
        if (! isset($post['page'])) {
            $post['page'] = 0; // 分页页数
        }
        
        if (! isset($post['pagesize'])) {
            $post['pagesize'] = 10; // 分页条数
        }
        $page = $post['page'];
        $pagesize = $post['pagesize'];
        $res = db('wh_jd_apply')->page($page,$pagesize)->select();
        if (!$res){
            err('暂无数据');
        }else{
            suc('',$res);
        }
    }
    
    /**
     * @SWG\Post(
     * path="/Whereabouts",
     * tags={"Whereabouts"},
     * summary="去向提交",
     * description="去向提交-吴辉",
     * @SWG\Parameter(name="mstr", description="加密KEY", in="formData", required=true, type="string"),
     * @SWG\Parameter(name="name", description="人员名称", in="formData", required=false, type="integer"),
     * @SWG\Parameter(name="content", description="去向", in="formData", required=false, type="integer"),
     * @SWG\Parameter(name="time", description="时间", in="formData", required=false, type="integer"),
     * @SWG\Response(
     * response=200,
     * description="成功返回数据",
     * )
     * )
     */
    public function Whereabouts()
    {
        $post = request()->only(['name','content','time'], 'post');
        if (empty($post['name'])){
            err('人员不能为空');
        }
        if (empty($post['time'])){
            err('时间不能为空');
        }
        if (empty($post['content'])){
            err('去向不能为空');
        }
        $data['name'] = $post['name'];
        $data['time'] = $post['time'];
        $data['content'] = $post['content'];
        $data['create_time'] = date("Y-m-d");
        $res = db('wh_jd_whereabouts')->insert($data);
        if (!$res){
            err('提交失败');
        }else{
            suc('提交成功');
        }
        
    }
    
    /**
     * @SWG\Post(
     * path="/Duty",
     * tags={"Duty"},
     * summary="值日提示",
     * description="值日提示-吴辉",
     * @SWG\Parameter(name="mstr", description="加密KEY", in="formData", required=true, type="string"),
     * @SWG\Parameter(name="page", description="分页", in="formData", required=false, type="integer"),
     * @SWG\Parameter(name="pagesize", description="分页页数", in="formData", required=false, type="integer"),
     * @SWG\Response(
     * response=200,
     * description="成功返回数据",
     * @SWG\Header(header="name", type="string", description="人员"),
     * @SWG\Header(header="content", type="string", description="去向"),
     * @SWG\Header(header="time_start", type="string", description="开始时间"),
     * @SWG\Header(header="time_end", type="string", description="结束时间"),
     * )
     * )
     */
    public function Duty()
    {
        $post = request()->only(['page','pagesize'], 'post');
        if (! isset($post['page'])) {
            $post['page'] = 0; // 分页页数
        }
        
        if (! isset($post['pagesize'])) {
            $post['pagesize'] = 10; // 分页条数
        }
        $page = $post['page'];
        $pagesize = $post['pagesize'];
        
        $res = db('wh_jd_duty')->page($page,$pagesize)->select();
        if (!$res){
            err('暂无数据');
        }else{
            suc('',$res);
        }
    }
    
    /**
     * @SWG\Post(
     * path="/Remarks",
     * tags={"Remarks"},
     * summary="备注列表",
     * description="备注列表-吴辉",
     * @SWG\Parameter(name="mstr", description="加密KEY", in="formData", required=true, type="string"),
     * @SWG\Parameter(name="page", description="分页", in="formData", required=false, type="integer"),
     * @SWG\Parameter(name="pagesize", description="分页页数", in="formData", required=false, type="integer"),
     * @SWG\Response(
     * response=200,
     * description="成功返回数据",
     * @SWG\Header(header="name", type="string", description="发布人"),
     * @SWG\Header(header="title", type="string", description="主题"),
     * @SWG\Header(header="content", type="string", description="内容"),
     * @SWG\Header(header="image", type="string", description="图片"),
     * )
     * )
     */
    public function Remarks()
    {
        $post = request()->only(['page','pagesize'], 'post');
        if (! isset($post['page'])) {
            $post['page'] = 0; // 分页页数
        }
        
        if (! isset($post['pagesize'])) {
            $post['pagesize'] = 10; // 分页条数
        }
        $page = $post['page'];
        $pagesize = $post['pagesize'];
        $res = db('wh_jd_remarks')->page($page,$pagesize)->select();
        foreach ($res as $k => $v){
            $res[$k]['image'] = json_decode($v['image']);
        }
        if (!$res){
            err('添加失败');
        }else{
            suc('',$res);
        }
        
    }
    
    /**
     * @SWG\Post(
     * path="/RemarksAdd",
     * tags={"Remarks"},
     * summary="备注添加",
     * description="备注添加-吴辉",
     * @SWG\Parameter(name="mstr", description="加密KEY", in="formData", required=true, type="string"),
     * @SWG\Parameter(name="name", description="发布人", in="formData", required=false, type="integer"),
     * @SWG\Parameter(name="title", description="主题", in="formData", required=false, type="integer"),
     * @SWG\Parameter(name="content", description="内容", in="formData", required=false, type="integer"),
     * @SWG\Parameter(name="image", description="图片", in="formData", required=false, type="integer"),
     * @SWG\Response(
     * response=200,
     * description="成功返回数据",
     * )
     * )
     */
    public function RemarksAdd($number)
    {
        

        $post = request()->only(['title','name','content','image'], 'post');
        if (empty($post['title'])){
            err('主题不能为空');
        }
        if (empty($post['name'])){
            err('发布人不能为空');
        }
        if (!empty($post['content'])){
            $data['content'] = $post['content'];
        }
        if (!empty($post['image'])){
            $data['image'] = json_encode($post['image']);
        }
        
        $data['create_time'] = date("Y-m-d");
        $data['title'] = $post['title'];
        $data['name'] = $post['name'];

        $res = db('wh_jd_remarks')->insert($data);
        if (!$res){
            err('添加失败');
        }else{
            suc('添加成功');
        }
    }
    

    
}








